#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    int N;
    while(cin >> N && N){
        list<int> l;
        for (int i = 1; i <= N; ++i) {
            l.push_back(i);
        }
        cout << "Discarded cards:";
        bool first = true;
        while(l.size()>1){
            int dis = l.front();
            l.pop_front();

            int mov = l.front();
            l.pop_front();
            l.push_back(mov);

            if(first) {cout << " " << dis; first = false;}
            else cout << ", " << dis;
        }
        cout << "\n";
        cout << "Remaining card: " << l.front() << "\n";
    }
    return 0;
}